<link href="/css/bootstrap.min.css" rel="stylesheet"/> 
<script type="text/javascript" src="/js/jquery-1.7.2.min.js"></script>
<div id="select-box" style="display: none;">
<select name="select-parent" id="select-parent">
    <option selected="selected">Parent</option>
    <?php $list = $this->datas;
    if($list){
        foreach ($list as $key => $value) {
            echo("<option>".$value['name']."</option>");
        }}
    ?>
</select>
<script>
    $("#select-parent").change(function () {
          var str = "";
          var scntDiv = $('#select-box');
          $("#select-parent option:selected").each(function () {
                str = $(this).text();
                $.post("/admin/type/index", { data: str, check: "type" });
              });
          $("#selected-parent").val(str);
    })
        .trigger('change');
</script>
</div>
<script type="text/javascript">
     $(document).ready( function()
	      {
		    	 $("#add_menu").click(function()
		    			 {
		    	    	 name = $("#name").val();
		    	         if(name == "") alert("Không được để trống ô Name");
		    	         description = $("#description").val();
		    	  )
	      });
</script>
	      
<div id='formadd'>
<form id="form1" name="form1" method="post" action="">
  <table width="800" border="0">
    <tr>
      <td width="115" height="45" style="font-weight: bold;">Thể loại:</td>
      <td width="263"><label>
        <input name="name" type="text" id="name" size="30" />
      </label></td>
      </tr><tr>
      <td width="121" style="font-weight: bold;">Mô tả:</td>
      <td width="283"><input name="description"  type="text" id="description" size="30" /></td>
      <td><input class="btn btn-primary" type="submit" name="submit" value="ADD" id="add_menu"/></td>
    </tr>
  </table>
  <label></label>
</form>
</div>
<div id='formnew'></div>

<table width="100%" cellspacing="0" cellpadding="2" border="0">
	
		<tr>
			<td align="left"><input type="button" class="btn btn-primary" width='30'  value="Add new category" id='new' name='new' onclick='showFormAdd()'></td>
			<td align="right"><a href="/admin/type/sorttype"><button>Sắp xếp</button></a></td>
		</tr>

</table>



<?php 
$list = $this->datas;
if($list){
?>


<div class="grid_9" id="dashtabs">
<div class="box-header"> Film Manager</div>
<div id="dashtabs-pages" class="box-content no-padding">

<table width="100%" cellspacing="0" cellpadding="4" border="0" class="table no-border">
	 <thead>
		<tr align="center" >
	    		<td width="20%" align="center"> Name </td>
	    		<td width="20%" align="center"> Nam types </td>
                <td width="5%" align="center"> Edit types </td>
				<td width="5%" align="center"> Edit </td>
				<td width="5%" align="center"> Delete </td>
				<td width="5%" align="center"> Status </td>
			</tr>
		 </thead>
		<tbody>
			<?php 			
			foreach ($list as $key => $value) {
				echo ($key % 2 == 0)?("<tr class='' id = '".$value['id']."'>"):("<tr class='alt' id = '".$value['id']."'>");
				echo "<td align='center'>".$value['name']."</td>";
				echo "<td align='center'>".$value['name_types']."</td>";
                echo "<td align='center'><a href='/admin/type/category?id=".$value['id']."'>Edit types</a></td>";
				echo "<td align='center'><img src='/images/adminbase/edit.png' width=32 height=32 onclick='edit_menu(".$value['id'].")'></td>";
				echo "<td align='center'><img src='/images/adminbase/delete.png' width=32 height=32 onclick='delete_menu(".$value['id'].")'></td>";
				?>
				<td align='center'> <?php if($value['status'] == 1) echo "<button type='button' class='btn btn-primary'  onclick=edit_status_menu(".$value['id'].",".$value['status'].") id='ma".$value['id']."'>ON</button>";
				                                                    else echo "<button type='button' class='btn btn-danger'  onclick=edit_status_menu(".$value['id'].",".$value['status'].") id='ma".$value['id']."'>OFF</button>"; ?>
				 </td>
				<?php 
				echo "</tr>";
			}
			?>
	</tbody>
</table>
     

</div>
<div class="box-footer"> <span class="txt-smaller txt-light">Showing <?php echo count($list);?> results </span></div>
</div>

<?php 
}
?>
